home *** CD-ROM | disk | FTP | other *** search
/ Win '95 Giga Pack / Win95 Giga Pack (Maple Media) (1997).iso / UTILITY / WNBT32 / FILEMENU.MN_ < prev    next >
Text File  |  1996-03-09  |  20KB  |  460 lines

  1.           editor="notepad.exe"    ;Default editor
  2.           ; Common menu for all file types
  3.           ;First figure out where filemenu.dll is installed via registry lookup
  4.           ErrorMode(@OFF)
  5.           wbdir=RegQueryValue(@REGMACHINE,"SOFTWARE\Wilson WindowWare\WinBatch\CurrentVersion")
  6.           if wbdir==0 
  7.              wbdir=RegQueryValue(@REGMACHINE,"SOFTWARE\Wilson WindowWare\WinBatch Compiler\CurrentVersion")
  8.           endif
  9.           ErrorMode(@CANCEL)
  10.           if wbdir==0 then Display(5,"Error","Registry entries missing.  Re-install WinBatch")
  11.           homedir=strcat(wbdir,"system\")
  12.  
  13.           ;Next see if WinEdit is lurking about via registry lookup
  14.           ErrorMode(@OFF)
  15.           WinEdit=strcat(RegQueryValue(@REGMACHINE,"SOFTWARE\Wilson WindowWare\WinEdit\CurrentVersion"),"WinEdit.exe")
  16.           ErrorMode(@CANCEL)
  17.           if WinEdit==0    ;No?  Try path
  18.              WinEdit=FileLocate("WINEDIT.EXE")
  19.              if WinEdit=="" then WinEdit=editor
  20.           endif
  21.  
  22.           inifile=strcat(DirWindows(0),"FileMenu.ini")
  23.           if !FileExist(inifile) then inifile=strcat(homedir,"FileMenu.ini")
  24.           commonmenu="FileMenu for all filetypes.mnw"
  25.           defaultmenu="FileMenu for misc filetypes.mnw"
  26.  
  27. Two Explorers, side by side ; Your dual window file manager
  28.         a=IntControl(31,0,0,0,0)  ;return list of ids of explorer windows
  29.         c=ItemCount(a,@TAB)
  30.         switch c
  31.            case 0
  32.               run("explorer.exe",strcat("/n,/e,",DirGet()))
  33.               while FindWindow("ExploreWClass")==""    ;wait for it to come up
  34.                 Yield
  35.               end while
  36.               ;Fall into case 1
  37.  
  38.            case 1
  39.               run("explorer.exe",strcat("/n,/e,",DirGet()))
  40.               break
  41.            case c       ; 2 or more
  42.               break
  43.         endswitch
  44.         d=1
  45.         while c<2 && d<500
  46.            a=IntControl(31,0,0,0,0)
  47.            c=ItemCount(a,@TAB)
  48.            d=d+1
  49.         endwhile
  50.         if c<2 then exit
  51.         id1=ItemExtract(1,a,@TAB)
  52.         id2=ItemExtract(2,a,@tab)
  53.         WinPlaceSet(@NORMAL,id2,"500 0 1000 900")
  54.         WinShow(id2)
  55.         Yield
  56.         Yield
  57.         WinPlaceSet(@NORMAL,id1,"0 0 500 900")
  58.         WinShow(id1)
  59.      
  60. Open With ... ; Choose an application to view or edit the selected file.
  61.  
  62.  &Browser (binary file viewer)  ; View any file in binary format.
  63.         file = CurrFilePath()
  64.         If !(FileExist(file)) Then file = ""
  65.         Else If FileExtension(file) == "" Then file = StrCat(file, ".")
  66.         Run("browser.exe", FileNameShort(file))     
  67.  &Notepad  ; Modify small plain text files.
  68.         file = CurrFilePath()
  69.         If !(FileExist(file)) Then file = ""
  70.         Else If FileExtension(file) == "" Then file = StrCat(file, ".")
  71.         Run("notepad.exe", file)
  72.  &MSPaint (bitmap) ; View and Modify bitmaps
  73.          file = CurrFilePath()
  74.          If !(FileExist(file)) Then file = ""
  75.               Else If FileExtension(file) == "" Then file = StrCat(file, ".")
  76.          bmpfile = strlower(FileExtension(file))
  77.          If bmpfile != "bmp"
  78.               Message("Error","Select a BMP file and try again.")
  79.               Exit
  80.          EndIf          
  81.          rkey=RegOpenKey(@REGMACHINE,"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths")
  82.          mspaintexe=RegQueryValue(rkey,"MSPAINT.EXE")
  83.          RegCloseKey(rkey)
  84.          Run(mspaintexe,file)
  85.  &Wordpad (text and graphics) ; Modify WORD, RTF, plain text files. Can contain bitmaps, too.
  86.          file = CurrFilePath()
  87.          If !(FileExist(file)) Then file = ""
  88.               Else If FileExtension(file) == "" Then file = StrCat(file, ".")
  89.          rkey=RegOpenKey(@REGMACHINE,"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths")
  90.          wordpadexe=RegQueryValue(rkey,"WORDPAD.EXE")
  91.          RegCloseKey(rkey)
  92.          Run(wordpadexe,file)
  93.  Win&Edit (text) ; Open file with WinEdit
  94.         f = CurrFilePath()
  95.         If !(FileExist(f)) Then f = ""
  96.         Else If FileExtension(f) == "" Then f = StrCat(f, ".")
  97.         Run(WinEdit, f)
  98.  
  99.      
  100. File Operations
  101.  
  102.  File/Folder size    ;Sum sizes of all highlighted files and folders
  103.         
  104.         tot = FileSize(FileItemize(""))
  105.         sub1 = DirItemize("")
  106.         totdir=0
  107.         level=1
  108.         dir1=DirGet()
  109.         
  110.         numdir1 = ItemCount(sub1, @tab)
  111.         index1 = 0
  112.   
  113.         :dsloop
  114.         If index%level% == numdir%level% Then Goto upalevel
  115.         index%level% = index%level% + 1
  116.         DirChange(StrCat(dir%level%, ItemExtract(index%level%, sub%level%, @tab)))
  117.         
  118.         totdir=totdir+1
  119.         tot = tot + FileSize(FileItemize("*.*"))
  120.         level = level + 1
  121.         dir%level% = DirGet()
  122.         sub%level% = DirItemize("*.*")
  123.         numdir%level% = ItemCount(sub%level%, @tab)
  124.         index%level% = 0
  125.         goto dsloop
  126.   
  127.         :upalevel
  128.         drop(dir%level%,sub%level%,index%level%,numdir%level%)
  129.         level=level-1
  130.         if level!=0 then goto dsloop
  131.  
  132.         ; -----------
  133.         ; Termination
  134.         ; -----------
  135.         
  136.         If StrLen(tot) < 9 Then tot = StrCat(StrFill("", 9 - StrLen(tot)), tot)
  137.         tot = StrCat(StrSub(tot,1,3),",",StrSub(tot,4,3),",",StrSub(tot,7,3))
  138.         tot = StrTrim(tot)
  139.         If StrSub(tot, 1, 1) == "," Then tot = StrSub(tot, 2, StrLen(tot) - 1)
  140.         tot = StrTrim(tot)
  141.         If StrSub(tot, 1, 1) == "," Then tot = StrSub(tot, 2, StrLen(tot) - 1)
  142.         tot = StrTrim(tot)
  143.         Message("%totdir% Subdirectories included", "Total size %tot% bytes.")
  144.  
  145.  Print (with Notepad)   ;Print text-type file with notepad on default printer
  146.         Run("notepad.exe",strcat("/p ",FileCurrPath())
  147.  Associate              ;Associate this type of file with an application
  148.         a=strlower(FileExtension(CurrentFile()))
  149.         b=AskFileName("Associate %a% files with","C:\","Executable Files|*.exe;*.com;*.bat;*.pif|All Files|*.*|","",1)
  150.     
  151.         rkey=RegOpenKey(@REGCLASSES,"")
  152.         ErrorMode(@OFF)
  153.         RegDeleteKey(rkey,".%a%")
  154.         ErrorMode(@CANCEL)
  155.         RegSetValue(rkey, ".%a%", "%a%_auto_file")
  156.         RegSetValue(rkey,"%a%_auto_file\shell\open\command",strcat('"',b,'" "%%1"'))
  157.         AU=StrUpper(a)
  158.         RegSetValue(rkey,"%a%_auto_file","%AU% File")
  159.         RegClosekey(rkey)
  160.  File Attributes        ;View file attributes
  161.         files = FileItemize("")
  162.         numfiles = ItemCount(files,@TAB)
  163.         While numfiles == 1
  164.         file = CurrentFile()
  165.         result = FileAttrGet(file)
  166.         If StrLen(file) > 30
  167.              fileindialog = StrSub(file,1,30)
  168.           
  169.              fileindialog = StrCat(fileindialog," ...")
  170.         Else 
  171.              fileindialog = file
  172.         EndIf
  173.      
  174.         readonly = 2
  175.         archive = 2
  176.         system = 2
  177.         hidden = 2
  178.         If StrSub(result,1,1) == "R" Then readonly = "3"
  179.         If StrSub(result,2,1) == "A" Then archive = "3"
  180.         If StrSub(result,3,1) == "S" Then system = "3"
  181.         If StrSub(result,4,1) == "H" Then hidden = "3"
  182.  
  183.                FileAttributesFormat=`WWWDLGED,5.0`
  184.                
  185.                FileAttributesCaption=`File Attributes`
  186.                FileAttributesX=7
  187.                FileAttributesY=25
  188.                FileAttributesWidth=199
  189.                FileAttributesHeight=101
  190.                FileAttributesNumControls=17
  191.                
  192.                FileAttributes01=`110,86,36,DEFAULT,PUSHBUTTON,DEFAULT,"&Cancel",0`
  193.                FileAttributes02=`42,18,38,DEFAULT,STATICTEXT,DEFAULT,"Read Only"`
  194.                FileAttributes03=`126,18,36,DEFAULT,STATICTEXT,DEFAULT,"System"`
  195.                FileAttributes04=`84,18,36,DEFAULT,STATICTEXT,DEFAULT,"Archive"`
  196.                FileAttributes05=`168,18,36,DEFAULT,STATICTEXT,DEFAULT,"Hidden"`
  197.                FileAttributes06=`56,86,36,DEFAULT,PUSHBUTTON,DEFAULT,"&OK",1`
  198.                FileAttributes07=`2,54,36,DEFAULT,STATICTEXT,DEFAULT,"On"`
  199.                FileAttributes08=`2,36,36,DEFAULT,STATICTEXT,DEFAULT,"Off"`
  200.                FileAttributes09=`2,4,194,DEFAULT,STATICTEXT,DEFAULT,"Set File Attributes for => %fileindialog% "`
  201.                FileAttributes10=`42,36,36,DEFAULT,RADIOBUTTON,readonly,"",2`
  202.                FileAttributes11=`42,54,36,DEFAULT,RADIOBUTTON,readonly,"",3`
  203.                FileAttributes12=`166,54,36,DEFAULT,RADIOBUTTON,hidden,"",3`
  204.                FileAttributes13=`84,36,36,DEFAULT,RADIOBUTTON,archive,"",2`
  205.                FileAttributes14=`84,54,36,DEFAULT,RADIOBUTTON,archive,"",3`
  206.                FileAttributes15=`166,36,36,DEFAULT,RADIOBUTTON,hidden,"",2`
  207.                FileAttributes16=`126,36,36,DEFAULT,RADIOBUTTON,system,"",2`
  208.                FileAttributes17=`126,54,36,DEFAULT,RADIOBUTTON,system,"",3`
  209.                
  210.                ButtonPushed=Dialog("FileAttributes")
  211.  
  212.  
  213.  
  214.            Select buttonpushed
  215.           
  216.                Case 0
  217.                     Break
  218.                     
  219.                Case 1
  220.  
  221.                     first = ""
  222.                     second = ""
  223.                     third = ""
  224.                     fourth = ""
  225.                     If readonly == 2 Then first = "r"
  226.                     If archive == 2 Then second = "a"
  227.                     If system == 2 Then third = "s"
  228.                     If hidden == 2 Then fourth = "h"
  229.                     If readonly == 3 Then first = "R"
  230.                     If archive == 3 Then second = "A"
  231.                     If system == 3 Then third = "S"
  232.                     If hidden == 3 Then fourth = "H"
  233.  
  234.                     
  235.                     
  236.                     
  237.                     attributes = StrCat( first, second, third, fourth )
  238.                     FileAttrSet(file, attributes)
  239.                     break
  240.            End Select
  241.                 
  242.  
  243.      Exit
  244.      EndWhile
  245.  
  246.      ;Set Attributes: Selected Files
  247.  
  248.      displayfiles = files
  249.      readonly = 1
  250.      archive = 1
  251.      system = 1
  252.      hidden = 1
  253.                AttribFormat=`WWWDLGED,5.0`
  254.                
  255.                AttribCaption=`Attributes`
  256.                AttribX=6
  257.                AttribY=25
  258.                AttribWidth=201
  259.                AttribHeight=101
  260.                AttribNumControls=22
  261.                
  262.                Attrib01=`110,86,36,DEFAULT,PUSHBUTTON,DEFAULT,"&Cancel",0`
  263.                Attrib02=`42,18,38,DEFAULT,STATICTEXT,DEFAULT,"Read Only"`
  264.                Attrib03=`126,18,36,DEFAULT,STATICTEXT,DEFAULT,"System"`
  265.                Attrib04=`84,18,36,DEFAULT,STATICTEXT,DEFAULT,"Archive"`
  266.                Attrib05=`168,18,36,DEFAULT,STATICTEXT,DEFAULT,"Hidden"`
  267.                Attrib06=`2,34,38,DEFAULT,STATICTEXT,DEFAULT,"No Change"`
  268.                Attrib07=`2,70,36,DEFAULT,STATICTEXT,DEFAULT,"On"`
  269.                Attrib08=`2,52,36,DEFAULT,STATICTEXT,DEFAULT,"Off"`
  270.                Attrib09=`42,34,36,DEFAULT,RADIOBUTTON,readonly,"",1`
  271.                Attrib10=`42,52,36,DEFAULT,RADIOBUTTON,readonly,"",2`
  272.                Attrib11=`42,70,36,DEFAULT,RADIOBUTTON,readonly,"",3`
  273.                Attrib12=`84,34,36,DEFAULT,RADIOBUTTON,archive,"",1`
  274.                Attrib13=`84,52,36,DEFAULT,RADIOBUTTON,archive,"",2`
  275.                Attrib14=`84,70,36,DEFAULT,RADIOBUTTON,archive,"",3`
  276.                Attrib15=`126,34,36,DEFAULT,RADIOBUTTON,system,"",1`
  277.                Attrib16=`126,52,36,DEFAULT,RADIOBUTTON,system,"",2`
  278.                Attrib17=`126,70,36,DEFAULT,RADIOBUTTON,system,"",3`
  279.                Attrib18=`168,34,36,DEFAULT,RADIOBUTTON,hidden,"",1`
  280.                Attrib19=`168,52,36,DEFAULT,RADIOBUTTON,hidden,"",2`
  281.                Attrib20=`168,70,36,DEFAULT,RADIOBUTTON,hidden,"",3`
  282.                Attrib21=`58,2,130,DEFAULT,STATICTEXT,DEFAULT,"Set Attributes for Selected Files"`
  283.                Attrib22=`56,86,36,DEFAULT,PUSHBUTTON,DEFAULT,"&OK",1`
  284.                
  285.                ButtonPushed=Dialog("Attrib")
  286.                
  287.  
  288.  
  289.  
  290.           Select buttonpushed
  291.           
  292.                Case 0
  293.                     Break
  294.                     
  295.                Case 1
  296.  
  297.                     first = ""
  298.                     second = ""
  299.                     third = ""
  300.                     fourth = ""
  301.                     If readonly == 2 Then first = "r"
  302.                     If archive == 2 Then second = "a"
  303.                     If system == 2 Then third = "s"
  304.                     If hidden == 2 Then fourth = "h"
  305.                     If readonly == 3 Then first = "R"
  306.                     If archive == 3 Then second = "A"
  307.                     If system == 3 Then third = "S"
  308.                     If hidden == 3 Then fourth = "H"
  309.  
  310.                     
  311.                     
  312.                     
  313.                     attributes = StrCat( first, second, third, fourth )
  314.                     FileAttrSet(files, attributes)
  315.                     break
  316.            End Select
  317.       Exit                              
  318.  
  319.  
  320.  DOS &Copy  ; Like the good, old, DOS COPY command.
  321.        s = StrTrim(FileItemize(""))
  322.        s=StrReplace(s,@tab,"|")
  323.        If s == "" Then Message("Copy Error", "No files selected")
  324.        Then Exit
  325.        If ItemCount(s, "|") == 1 Then t = s
  326.        Else t = ""
  327.        t = AskLine("Copy", StrCat(s, @CRLF, @CRLF, "to"), t)
  328.        If t == "" Then Message("Copy Error", "Cannot copy to null file name")
  329.                Then Exit
  330.        FileCopy(s, t, @TRUE)
  331.  
  332.  DOS &Rename  ;Like the good, old DOS RENAME command.
  333.        s = StrTrim(FileItemize(""))
  334.        s=StrReplace(s,@tab,"|")
  335.        If s == "" Then Message("Rename Error", "No files selected")
  336.        Then Exit
  337.        If ItemCount(s, "|") == 1 Then t = s
  338.        Else t = ""
  339.        t = AskLine("Rename", StrCat(s, @CRLF, @CRLF, "to"), t)
  340.        If t == "" Then Message("Rename Error", "Cannot rename to null file name")
  341.                   Then Exit
  342.        FileRename(s, t)
  343.  
  344.   
  345. Clipboard Tricks ; Copies just the filenames to the clipboard
  346.  FileName(s) to Clipboard ; Just the filenames
  347.         a=FileItemize("")
  348.         a=ItemSort(a,@tab)
  349.         a=strreplace(a,@TAB,@CRLF)
  350.         ClipPut(a)
  351.         Display(2,"Filenames placed on Clipboard",a)
  352.  Path and FileName(s) to Clipboard ; Copies filenames with full paths to the Clipboard
  353.         a=FileItemize("")
  354.         a=ItemSort(a,@TAB)
  355.         a=strcat(@TAB,StrSub(a,1,strlen(a)-1))
  356.         b=DirGet()
  357.         a=StrSub(StrReplace(a,@TAB,strcat(@TAB,b)),2,-1)
  358.         a=StrReplace(a,@TAB,@CRLF)
  359.         ClipPut(a)
  360.         Display(2,"Full path filenames placed on Clipboard",a)
  361.  Path to Clipboard   ; Copies just the path to the clipboard
  362.         a=DirGet()
  363.         ClipPut(a)
  364.         Display(2,"Path placed on Clipboard",a)
  365.         
  366.         
  367.  _Run Clipboard Viewer   ; Lets you see what is on the clipboard
  368.         Run("clipbd.exe","")
  369.  
  370.  
  371. WIL Interactive
  372.  Execute a function
  373.         call("%homedir%wwwmenu95.wil","CMDSTACK NEWCMD")
  374.  _Load WIL Help File
  375.         WinHelp(strcat(wbdir,"Windows Interface Language.hlp"),"CONTENTS","")     
  376.       
  377.  
  378.  
  379.      
  380. _Edit File Menus ; Modify WinBatch FileMenus here 
  381.  Edit menu for this filetype  ; Edit menus for files with a specific file extension.
  382.         b=strupper(FileExtension(CurrentFile()))
  383.         a=IniReadPvt("Menus",b,"*NONE*",inifile)
  384.         c=a
  385.         if c=="*NONE*" then a=strcat("FileMenu for %b% files",".mnw")
  386.         if FilePath(a)=="" then a=strcat(HomeDir,a)
  387.         ;Message(a,FileExist(a))
  388.         if  FileExist(a)
  389.                 if c=="*NONE*"
  390.                    iniwritepvt("Menus",b,a,inifile)
  391.                    Display(7,"%b% was missing from %inifile%","Adding menu file back in now")
  392.                 endif
  393.         else
  394.                 c=AskYesNo("Please note:","The menu file for the %b% filetype does not exist.  Would you like to start a new one?")
  395.                 if c==@NO then exit
  396.                 c=               "; WinBatch FileMenu for %b% filetype%@CRLF%"
  397.                 c=strcat(c,@CRLF,"; This is a sample menu file to help you get started")
  398.                 c=strcat(c,@CRLF,"; writing your very own Winbatch FileMenu menus.  It is")
  399.                 c=strcat(c,@CRLF,"; really not too bad.  WinBatch is a simple programming")
  400.                 c=strcat(c,@CRLF,"; language.  You can find out just about all you need to")
  401.                 c=strcat(c,@CRLF,"; know from the Windows Interface Language help file or")
  402.                 c=strcat(c,@CRLF,"; the manual.  Check out the section on Menu Files,")
  403.                 c=strcat(c,@CRLF,"; the WIL Tutorial and the WIL Function Reference.")
  404.  
  405.                 c=strcat(c,@CRLF,@CRLF,'Standalone menu item            ; Sample menu item')
  406.                 c=strcat(c,@CRLF,      '        Message("Hello","There")')
  407.                 c=strcat(c,@CRLF,@CRLF,'Top Level menu item')
  408.                 c=strcat(c,@CRLF,      ' Selected File is               ; Shows currently selected file')
  409.                 c=strcat(c,@CRLF,      '        a=CurrFilePath()')
  410.                 c=strcat(c,@CRLF,      '        Message("Selected File is",a)')
  411.                 c=strcat(c,@CRLF,      ' Run Calculator                 ; Sample Run function')
  412.                 c=strcat(c,@CRLF,      '        Run("calc.exe","")')
  413.                 c=strcat(c,@CRLF,      ' Run Notepad on selected file   ; Sample Run function with filename')
  414.                 c=strcat(c,@CRLF,      '        a=CurrFilePath()')
  415.                 c=strcat(c,@CRLF,      '        Run("notepad.exe",a)')
  416.  
  417.                 c=strcat(c,@CRLF,@CRLF,'; Note: You may want to delete this menu item if you edit this file')
  418.                 c=strcat(c,@CRLF,      ' _Delete this sample menu file  ; Deletes this menu file')
  419.  
  420.                 c=strcat(c,@CRLF,      '        inifile=strcat(DirWindows(0),"FileMenu.ini")')
  421.                 c=strcat(c,@CRLF,      '        if !FileExist(inifile) then inifile=strcat(homedir,"FileMenu.ini")')
  422.  
  423.  
  424.                 c=strcat(c,@CRLF,      '        b=strupper(FileExtension(CurrentFile()))')
  425.                 c=strcat(c,@CRLF,      '        a=IniReadPvt("Menus",b,"*NONE*",inifile)')
  426.                 c=strcat(c,@CRLF,      '        if a=="*NONE*" then a=strcat("FileMenu for %b% files",".mnw")')
  427.                 c=strcat(c,@CRLF,      '        if FilePath(a)=="" then a=strcat(HomeDir,a)')
  428.                 c=strcat(c,@CRLF,      '        c=AskYesNo("Are you sure you wish to delete this menu file",a)')
  429.                 c=strcat(c,@CRLF,      '        if c==@YES')
  430.                 c=strcat(c,@CRLF,      '           IniDeletePvt("Menus",b,inifile)')
  431.                 c=strcat(c,@CRLF,      '           FileDelete(a)')
  432.                 c=strcat(c,@CRLF,      '        endif')
  433.  
  434.  
  435.  
  436.  
  437.                 c=strcat(c,@CRLF)
  438.                 fh=FileOpen(a,"WRITE")
  439.                 FileWrite(fh,c)
  440.                 FileClose(fh)
  441.                 iniwritepvt("Menus",b,a,inifile)
  442.                 drop(c)
  443.                 
  444.         endif
  445.         Run(Editor,a)
  446.  ;Edit the Miscellaneous File Menu     ; Edit menus for files with unrecognized extensions
  447.  ;       a=IniReadPvt("FileMenu","DefaultMenu",defaultmenu,inifile)
  448.  ;       a=strcat(HomeDir,a)
  449.  ;       Run(Editor,a)
  450.  Edit menu for all filetypes      ; Edit global menu for all files 
  451.         a=IniReadPvt("FileMenu","CommonMenu",commonmenu,inifile)
  452.         a=strcat(HomeDir,a)
  453.         Run(Editor,a) 
  454.  _Load WIL Help File
  455.         WinHelp(strcat(wbdir,"Windows Interface Language.hlp"),"CONTENTS","")     
  456.  
  457.  _About WinBatch FileMenu  ; Software from Wilson WindowWare
  458.         About()           
  459.            
  460.